﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace SangsTools
{
    public class AutoSetBgSize : OnSizeChange
    {
        public RectTransform tfBG;
        public Vector2 vAddSize;

        protected override void OnUISizeChange(Vector2 size)
        {
            if (tfBG != null)
                tfBG.sizeDelta = size + vAddSize;
        }

        [ContextMenu("Refresh")]
        private void Refresh()
        {
            if (tfBG != null)
            {
                tfBG.sizeDelta = MyTransform.sizeDelta + vAddSize;
#if UNITY_EDITOR
                UnityEditor.EditorUtility.SetDirty(tfBG.transform);
#endif
            }
        }
    }
}
